package com.example.my2lcache.common;


import com.example.my2lcache.utils.SerializerUtils;
import com.example.my2lcache.utils.serializer.JavaSerializer;

/**
 * 序列化类型枚举
 *
 * @author huhao
 */
public enum SerializerTypeEnum {

    JAVA("java", new JavaSerializer());

    private final String type;

    private final SerializerUtils serializer;

    SerializerTypeEnum(String type, SerializerUtils serializer) {
        this.type = type;
        this.serializer = serializer;
    }

    public String getType() {
        return type;
    }

    public SerializerUtils getSerializer() {
        return serializer;
    }

    public static SerializerTypeEnum match(String type) {
        for (SerializerTypeEnum item : SerializerTypeEnum.values()) {
            if (item.getType().equals(type)) {
                return item;
            }
        }
        return null;
    }
}
